#pragma once

#include <QAbstractListModel>

#include "tccore_global.h"

namespace TC
{
    namespace Data
    {
        class TCCORE_EXPORT AbstractQmlModel : public QAbstractListModel
        {
            Q_OBJECT;
            Q_PROPERTY(uint count READ rowCount NOTIFY countChanged)
        public:
            AbstractQmlModel();
            Q_SIGNAL void countChanged();
        public:
            Q_INVOKABLE QVariant get(uint index);
        public:
            void add(const QVariantMap &data);
            void add(const QList<QVariantMap> &data);

            virtual Q_INVOKABLE QHash<int, QByteArray> roleNames() const override;
            virtual Q_INVOKABLE int rowCount(const QModelIndex & parent = QModelIndex()) const override;
            virtual Q_INVOKABLE QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;
        private:
            QList<QVariantMap> _data;
        };
    }
}